<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script>
    var showColor
    window.onload = function () {
      showColor = document.getElementById('three')
    }
    function showBody(colorDiv) {
       showColor.style.backgroundColor=null;
       var colorObj = document.getElementById(colorDiv)
       colorObj.style.backgroundColor="red";
       showColor = colorObj;
    }
  </script>
</head>
<body>
  <table border="1px" width="500px" cellspacing="0">
    <thead>
    <tr><th>姓名</th><th>性别</th><th>爱好</th></tr>
    </thead>
    <tbody style="text-align: center">
     <tr onclick=showBody("one") id="one"><td>张三</td><td>男</td><td>吃饭</td></tr>
     <tr onclick=showBody("two") id="two"><td>李四</td><td>男</td><td>睡觉</td></tr>
     <tr onclick=showBody("three") id="three"><td>王云</td><td>女</td><td>跑步</td></tr>
    </tbody>

  </table>
</body>
</html>
